package cn.wps.moffice.common.beans.phone; import android.content.Context; import android.graphics.Canvas; import android.os.Build; import android.util.AttributeSet; import android.widget.ImageView; public class AlphaImageView extends ImageView { private boolean cMo = true; private boolean cMp = false; private int mAlpha = 255; public AlphaImageView(Context context) { super(context); } public AlphaImageView(Context context, AttributeSet attributeSet) { super(context, attributeSet); c(attributeSet); } public AlphaImageView(Context context, AttributeSet attributeSet, int i) { super(context, attributeSet, i); c(attributeSet); } private void c(AttributeSet attributeSet) { if (attributeSet != null) { setEnabled(attributeSet.getAttributeBooleanValue("http://schemas.android.com/apk/res/android", "enabled", true)); setPressAlphaEnabled(attributeSet.getAttributeBooleanValue(null, "pressAlphaEnabled", true)); } } public void draw(Canvas canvas) { if (255 != this.mAlpha) { canvas.saveLayerAlpha(0.0f, 0.0f, (float) getWidth(), (float) getHeight(), this.mAlpha, 20); } super.draw(canvas); } public void refreshDrawableState() { int i = 255; if (!isEnabled()) { this.mAlpha = 71; } else if (Build.VERSION.SDK_INT < 21 || this.cMp) { if (isPressed() && this.cMo) { i = 76; } this.mAlpha = i; } else { this.mAlpha = 255; } super.refreshDrawableState(); invalidate(); } public void setForceAlphaEffect(boolean z) { this.cMp = z; } public void setPressAlphaEnabled(boolean z) { this.cMo = z; } }